package app.aaps.database.persistence.converters

import app.aaps.core.data.model.BCR
import app.aaps.database.entities.BolusCalculatorResult

fun BolusCalculatorResult.fromDb(): BCR =
    BCR(
        id = this.id,
        version = this.version,
        dateCreated = this.dateCreated,
        isValid = this.isValid,
        referenceId = this.referenceId,
        timestamp = this.timestamp,
        utcOffset = this.utcOffset,
        ids = this.interfaceIDs.fromDb(),
        targetBGLow = this.targetBGLow,
        targetBGHigh = this.targetBGHigh,
        isf = this.isf,
        ic = this.ic,
        bolusIOB = this.bolusIOB,
        wasBolusIOBUsed = this.wasBolusIOBUsed,
        basalIOB = this.basalIOB,
        wasBasalIOBUsed = this.wasBasalIOBUsed,
        glucoseValue = this.glucoseValue,
        wasGlucoseUsed = this.wasGlucoseUsed,
        glucoseDifference = this.glucoseDifference,
        glucoseInsulin = this.glucoseInsulin,
        glucoseTrend = this.glucoseTrend,
        wasTrendUsed = this.wasTrendUsed,
        trendInsulin = this.trendInsulin,
        cob = this.cob,
        wasCOBUsed = this.wasCOBUsed,
        cobInsulin = this.cobInsulin,
        carbs = this.carbs,
        wereCarbsUsed = this.wereCarbsUsed,
        carbsInsulin = this.carbsInsulin,
        otherCorrection = this.otherCorrection,
        wasSuperbolusUsed = this.wasSuperbolusUsed,
        superbolusInsulin = this.superbolusInsulin,
        wasTempTargetUsed = this.wasTempTargetUsed,
        totalInsulin = this.totalInsulin,
        percentageCorrection = this.percentageCorrection,
        profileName = this.profileName,
        note = this.note
    )

fun BCR.toDb(): BolusCalculatorResult =
    BolusCalculatorResult(
        id = this.id,
        version = this.version,
        dateCreated = this.dateCreated,
        isValid = this.isValid,
        referenceId = this.referenceId,
        timestamp = this.timestamp,
        utcOffset = this.utcOffset,
        interfaceIDs_backing = this.ids.toDb(),
        targetBGLow = this.targetBGLow,
        targetBGHigh = this.targetBGHigh,
        isf = this.isf,
        ic = this.ic,
        bolusIOB = this.bolusIOB,
        wasBolusIOBUsed = this.wasBolusIOBUsed,
        basalIOB = this.basalIOB,
        wasBasalIOBUsed = this.wasBasalIOBUsed,
        glucoseValue = this.glucoseValue,
        wasGlucoseUsed = this.wasGlucoseUsed,
        glucoseDifference = this.glucoseDifference,
        glucoseInsulin = this.glucoseInsulin,
        glucoseTrend = this.glucoseTrend,
        wasTrendUsed = this.wasTrendUsed,
        trendInsulin = this.trendInsulin,
        cob = this.cob,
        wasCOBUsed = this.wasCOBUsed,
        cobInsulin = this.cobInsulin,
        carbs = this.carbs,
        wereCarbsUsed = this.wereCarbsUsed,
        carbsInsulin = this.carbsInsulin,
        otherCorrection = this.otherCorrection,
        wasSuperbolusUsed = this.wasSuperbolusUsed,
        superbolusInsulin = this.superbolusInsulin,
        wasTempTargetUsed = this.wasTempTargetUsed,
        totalInsulin = this.totalInsulin,
        percentageCorrection = this.percentageCorrection,
        profileName = this.profileName,
        note = this.note
    )
